<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTradeQueuesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('trade_queues', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id');
            $table->unsignedDecimal('amount',30,0)->comment('金额');
            $table->unsignedDecimal('unmatch_amount',30,0)->comment('未匹配金额');
            $table->boolean(' queue_task_done')->default(0)->comment('防止异步');

            $table->unsignedBigInteger('all_match_ts_at')->nullable()->comment('未匹配金额等于0 == 匹配结束时间');
            $table->enum('status', ['matching','pending','done'])->default('matching')->comment('正在匹配 matching | 1 交易中 pending  | 2 完成 done |');

            $table->enum('type',['deposit','withdraw'])->comment('deposit 入金| withdraw出金');

            $table->string('is_error')->default(false)->comment('异常');
            $table->unsignedBigInteger('created_at');
            $table->unsignedBigInteger('updated_at');

            $table->foreign('user_id')->references('id')->on('users');

        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('trade_queues');
    }
}
